/*
 * commons is a based project implemented
 * Copyright (C) 2024 Jasmine
 */
package com.commons.core.exception;

/**
 * 统一错误码异常
 */
public class GlobalErrorInfoException extends RuntimeException {

    private static final long serialVersionUID = -8300491678342431098L;

    private ResultInfoInterface errorInfo;

    public GlobalErrorInfoException() {}

    public GlobalErrorInfoException(ResultInfoInterface errorInfo) {
        this.errorInfo = errorInfo;
    }

    public GlobalErrorInfoException(String message) {
        this.errorInfo = new GlobalResultInfo(GlobalResultInfoEnum.FAILED.getCode(), message);
    }

    public GlobalErrorInfoException(int code, String message) {
        this.errorInfo = new GlobalResultInfo(code, message);
    }

    public ResultInfoInterface getErrorInfo() {
        return errorInfo;
    }

    public void setErrorInfo(ResultInfoInterface errorInfo) {
        this.errorInfo = errorInfo;
    }
}
